import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBImageStyle/YBImageStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBMineModel/YBMineAuthVipModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBModule/YBMineModule/YBMineProvider/YBMineUserProvider.dart';

class YBMyQuanYiMainPage extends StatelessWidget {

  String userInfoStr = "";
  String vipShengFengStr = "";
  String number = "";
  String shareHuiStr = "";
  String quanCengStr = "";
  String imageStr;
  @override
  Widget build(BuildContext context) {
    return Container(
       child: Scaffold(
         appBar: AppBar(
           elevation: 0,
           title: Text(YBChineseText.mineMyQuanYiTitle,style: YBTextStyle.TextStyle30313320Medium),
         ),
         body: SingleChildScrollView(
           child: ChangeNotifierProvider(create:(context)=>YBMineUserProvider()..getUserInfoData(),
           child: Consumer<YBMineUserProvider>(builder:(context,userInfo,child){
              if (userInfo.mineUserInfoModel != null){
                userInfoStr = (userInfo.mineUserInfoModel.customerPhone != null)?'尊敬的${userInfo.mineUserInfoModel.customerPhone}，您好':"";
                if (userInfo.mineUserInfoModel.certStatus != 2){
                  shareHuiStr = YBChineseText.mineWeiKaiTongTitle;
                  quanCengStr = YBChineseText.mineWeiKaiTongTitle;
                }else{
                  shareHuiStr = YBChineseText.mineYiKaiTongTitle;
                  quanCengStr = YBChineseText.mineYiKaiTongTitle;
                }
                number = '0/0';
                vipShengFengStr = YBChineseText.mineZuCeHuiYuanTitle;
                for( YBMineAuthVipModel mineAuthModel in userInfo.mineUserInfoModel.customerAuthorities){
                  if (mineAuthModel.authority.contains('BLVIP')) {
                    vipShengFengStr = YBChineseText.mineRenZhengHuiYuanTitle;
                    number = '${userInfo.mineUserInfoModel.useOrgNumber}/${userInfo.mineUserInfoModel.orgMaxNumber}';
                    break;
                  }else{
                    number = '0/0';
                    vipShengFengStr = YBChineseText.mineZuCeHuiYuanTitle;
                  }
                }
                imageStr = userInfo.mineUserInfoModel.avatarUrl;
              }else{
                 userInfoStr ='尊敬的贵宾，您好';
              }

              return Stack(
               children: [
                 Container(
                   child: Image.asset(YBImageStyle.getImagePath('mine_myquanyi')),
                 ),
                 Container(
                   child: Padding(
                     padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize30),
                     child: Row(
                       children: [
                         Container(
                           child: ClipRRect(
                             borderRadius: BorderRadius.circular(YBTextStyle.adapterSize30),
                             child: CachedNetworkImage(imageUrl:imageStr??"",width: YBTextStyle.adapterSize60,height: YBTextStyle.adapterSize60,),
                           ),
                         ),
                         Container(
                           width: YBTextStyle.adapterSize20,
                         ),
                         Container(
                           child: Column(
                             children: [
                               Container(
                                 child: Text(
                                   userInfoStr??"",
                                   style: YBTextStyle.TextStyleFFFFFF16Medium,
                                 ),
                               ),
                               Container(
                                 height: YBTextStyle.adapterSize10,
                               ),
                               Container(
                                 child: Text(
                                   "您的身份：$vipShengFengStr",
                                   style: YBTextStyle.TextStyleFFFFFF13,
                                 ),
                               ),
                             ],
                           ),
                         ),
                       ],
                     ),
                   ),
                 ),
                 Container(
                   child: Padding(
                     padding: EdgeInsets.only(left: YBTextStyle.adapterSize20,right: YBTextStyle.adapterSize20,top: YBTextStyle.adapterSize110),
                     child: Container(
                       decoration: BoxDecoration(
                         borderRadius: BorderRadius.all(Radius.circular(YBTextStyle.adapterSize8)),
                         color: YBColor.white,
                       ),
                       child: Padding(
                         padding: EdgeInsets.only(left:YBTextStyle.adapterSize15,right: YBTextStyle.adapterSize15,top: YBTextStyle.adapterSize15,bottom: YBTextStyle.adapterSize15),
                         child: Column(
                           mainAxisAlignment: MainAxisAlignment.start,
                           crossAxisAlignment: CrossAxisAlignment.stretch,
                           children: [
                             Container(
                               height: YBTextStyle.adapterSize48,
                               child: Text(
                                 YBChineseText.mineCurrentZhangHaoQuanYiTitle,
                                 style: YBTextStyle.TextStyle383A3D15Medium,
                               ),
                             ),
                             Container(
                               height: 1.0,
                               color: YBColor.colorF5F5F7,
                             ),
                             Container(
                               height: YBTextStyle.adapterSize48,
                               child: Row(
                                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                 crossAxisAlignment: CrossAxisAlignment.center,
                                 children: [
                                   Container(
                                     child: Text(
                                       YBChineseText.minePrimeQuanCengTitle,
                                       style: YBTextStyle.TextStyle383A3D14,
                                     ),
                                   ),
                                   Container(
                                     child: Text(
                                       quanCengStr??YBChineseText.mineWeiKaiTongTitle,
                                       style: YBTextStyle.TextStyleA9AEB812,
                                     ),
                                   ),
                                 ],
                               ),
                             ),
                             Container(
                               height: 1.0,
                               color: YBColor.colorF5F5F7,
                             ),
                             Container(
                               height: YBTextStyle.adapterSize48,
                               child: Row(
                                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                 crossAxisAlignment: CrossAxisAlignment.center,
                                 children: [
                                   Container(
                                     child: Text(
                                       YBChineseText.mineFengXiangHuiTitle,
                                       style: YBTextStyle.TextStyle383A3D14,
                                     ),
                                   ),
                                   Container(
                                     child: Text(
                                       shareHuiStr??YBChineseText.mineWeiKaiTongTitle,
                                       style: YBTextStyle.TextStyleA9AEB812,
                                     ),
                                   ),
                                 ],
                               ),
                             ),
                             Container(
                               height: 1.0,
                               color: YBColor.colorF5F5F7,
                             ),
                             Container(
                               height: YBTextStyle.adapterSize48,
                               child: Row(
                                 mainAxisAlignment: MainAxisAlignment.spaceBetween,
                                 crossAxisAlignment: CrossAxisAlignment.center,
                                 children: [
                                   Container(
                                     child: Text(
                                       YBChineseText.mineZhangHaoShuLiangTitle,
                                       style: YBTextStyle.TextStyle383A3D14,
                                     ),
                                   ),
                                   Container(
                                     child: Text(
                                       number??"0/0",
                                       style: YBTextStyle.TextStyleA9AEB812,
                                     ),
                                   ),
                                 ],
                               ),
                             ),
                           ],
                         ),
                       ),
                     ),
                   ),
                 ),
               ],
             );
           }),
           ),
         ),
       ),
    );
  }
}
